fix: prevent file path corruption in tool execution across all tools #9300
+6
−6
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR attempts to address the broader tool usage issues reported in #9239 and #9298. Feedback and guidance are welcome.
Problem
The
removeClosingTagfunction was being incorrectly used in theexecutemethods of several tools. This function is designed to clean up partial XML tag artifacts during streaming (inhandlePartialmethods), but was being misused on actual parameter values like file paths.This caused:
/root/oxyde_strat/stratoxyde-v2/src/services/storage/saveStates.tswould create a file named "str")Root Cause
The
removeClosingTagfunction uses a regex pattern to remove partial closing XML tags that might appear at the end of streamed content. When incorrectly applied to actual file paths inexecutemethods, it would strip characters that happen to match partial tag patterns, corrupting the paths.Solution
removeClosingTagcalls fromexecutemethods in:removeClosingTagremains available for its intended purpose inhandlePartialmethodsChanges
Testing
Related Issues
Impact
This fix ensures that all tools correctly handle file paths and other parameters without corruption, improving reliability across all AI models using the tool system.
Important
Fixes file path corruption by removing incorrect
removeClosingTagcalls in tool execution methods.removeClosingTagcalls fromexecutemethods inWriteToFileTool,GenerateImageTool, andaccessMcpResourceTool.accessMcpResourceTool.This description was created by
for b470bb0. You can customize this summary. It will automatically update as commits are pushed.